﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Configuration;

namespace Puman
{
    public static class Mailer
    {
        public static void Send(string email, string urlContent)
        {
            using (MailMessage message = new MailMessage())
            {
                SmtpClient mailClient = new SmtpClient();
                mailClient.Host = ConfigurationManager.AppSettings["Smtp"]; //指定SMTP服务名  例如QQ邮箱为 smtp.qq.com 新浪cn邮箱为 smtp.sina.cn等
                mailClient.Port = int.Parse(ConfigurationManager.AppSettings["Port"]); //指定端口号

                var from = ConfigurationManager.AppSettings["From"];
                var pwd = ConfigurationManager.AppSettings["Pwd"];
                mailClient.Credentials = new System.Net.NetworkCredential(from, pwd);
                message.From = new MailAddress(from);
                message.To.Add(new MailAddress(email)); //收件人邮箱
                message.Subject = ConfigurationManager.AppSettings["Subject"];//邮件主题
                message.Body = urlContent;  //邮件正文



                mailClient.Send(message);

            }


        }


    }
}
